package com.xinke.module.system.mapper.user;

import java.util.*;

import com.xinke.component.common.pojo.PageResult;
import com.xinke.component.mybatis.mybatis.core.query.LambdaQueryWrapperExt;
import com.xinke.component.mybatis.mybatis.core.mapper.BaseMapperExt;
import com.xinke.module.system.model.entity.user.DeptDO;
import org.apache.ibatis.annotations.Mapper;
import com.xinke.module.system.model.vo.user.*;

/**
 * 部门 Mapper
 *
 * @author yzx
 */
@Mapper
public interface DeptMapper extends BaseMapperExt<DeptDO> {

    default PageResult<DeptDO> selectPage(DeptPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperExt<DeptDO>()
                .likeIfPresent(DeptDO::getDeptName, reqVO.getDeptName())
                .eqIfPresent(DeptDO::getParentId, reqVO.getParentId())
                .eqIfPresent(DeptDO::getShowSort, reqVO.getShowSort())
                .eqIfPresent(DeptDO::getLeaderUserId, reqVO.getLeaderUserId())
                .eqIfPresent(DeptDO::getDeptPhone, reqVO.getDeptPhone())
                .eqIfPresent(DeptDO::getDeptEmail, reqVO.getDeptEmail())
                .eqIfPresent(DeptDO::getDeptStatus, reqVO.getDeptStatus())
                .orderByDesc(DeptDO::getDeptId));
    }

    default List<DeptDO> selectListByParentId(Collection<Long> parentIds) {
        return selectList(DeptDO::getParentId, parentIds);
    }
}